﻿var loadPrice = function (typeElement, scheduleElement, priceElement) {
    $(scheduleElement).change(function () {
        var typeId = parseInt(typeElement);
        var scheduleId = $(scheduleElement).val();



        $.ajax({
            type: "POST",
            url: "/ajax.html",
            data: { "function": "PriceListByShedule", "TypeId": typeId, "ScheduleId": scheduleId },
            dataType: "json",
            success: function (data) {
                if (typeId == 1 || typeId == 2 || typeId == 3) {
                    $(priceElement).html('<option value="-1">--- Chọn vé ---</option>');
                }
                
                if (data && data.isError == false) {
                    $.each(data.array, function (index, item) {
                        $(priceElement)
                            .append($("<option></option>")
                                .attr("value", item.ID)
                                .text(item.Name));
                    });
                }
            }
        });

    });
};



var loadPricebyHotel = function (hotelElement, priceElement) {

    $(hotelElement).change(function () {
        var hotelId = $(this).val();

        $.ajax({
            type: "POST",
            url: "/ajax.html",
            data: { "function": "ListPriceByHotel", "HotelId": hotelId },
            dataType: "json",
            success: function (data) {
                $(priceElement).html('<option value="-1">--- Chọn loại giá phòng ---</option>');

                if (data && data.isError == false) {
                    $.each(data.array, function (index, item) {
                        $(priceElement)
                            .append($("<option></option>")
                                .attr("value", item.ID)
                                .text(item.Name));
                    });
                }
            }
        });
    });
};

